import Vue from 'vue'
import Router from 'vue-router'
import VueRouter from 'vue-router'
import Layout from '../views/Layout.vue'
import Home from '../views/home/Home.vue'

Vue.use(VueRouter)

const originalPush = Router.prototype.push
Router.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

const routes = [
  {
    path: '/',
    name: 'Layout',
    component: Layout,
    children: [
      {
        path: '/',
        name: 'Home',
        component: Home,
        props: true
      },
      {
        path: '/host',
        name: 'Host',
        component: () => import('../views/host')
      },
      {
        path: '/addmain',
        name: 'AddMain',
        component: () => import('../views/addMain')
      },
      {
        path: '/about',
        name: "About",
        component: () => import('../views/about')
      }
    ]
  },
  {
    path: '/login',
    name: "Login",
    component: () => import('../views/Login')
  },
  {
    path: "/register",
    name: "Register",
    component: () => import("../views/Register")
  }, {
    path: "/details/:id/:name/:price/:height/:weight/:img/:age/:phone/:remark/:introduction",
    name: "Details",
    component: () => import("../views/home/Details"),
    props: true
  },
  {
    path: "*",
    name: "NotFound",
    component: () => import('../views/errorPage/404')
  },
  // 主持人个人中心
  {
    path: "/center/host",
    name: "Reserve",
    component: () => import("../views/Center/Host/Reserve")
  },
  // 新人个人中心
  {
    path: '/center/new',
    name: "NewcomerPage",
    component: () => import('../views/Center/Newcomer/NewcomerPage')
  },
  // 婚庆公司个人中心
  {
    path: '/center/company',
    name: "WeddingHome",
    component: () => import('../views/Center/Wedding/WeddingHome')
  },
  // 策划师个人中心
  {
    path: '/center/planner',
    name: "PlannerHome",
    component: () => import('../views/Center/Planner/PlannerHome')
  },
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
